﻿using System;
using System.Data;
using System.Collections.Generic;
using FiberRMS.Model.AlarmManager;
namespace FiberRMS.BLL.AlarmManager
{
    /// <summary>
    /// 业务逻辑类ALARM_FAULTBILL 的摘要说明。
    /// </summary>
    public class ALARM_FAULTBILL
    {
        private readonly FiberRMS.DAL.AlarmManager.ALARM_FAULTBILL dal = new FiberRMS.DAL.AlarmManager.ALARM_FAULTBILL();
        public ALARM_FAULTBILL()
        { }
        #region  成员方法
        public string GetMaxID(DateTime dt)
        {
            object obj = dal.GetMaxID(dt);
            int maxid = 0;
            if (obj != null)
            {
                maxid = Convert.ToInt32(obj) + 1;
            }
            else
            {
                maxid = 1000;
            }
            return dt.ToString("yyyyMMdd") + maxid.ToString();
        }
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string BILLID)
        {
            return dal.Exists(BILLID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(FiberRMS.Model.AlarmManager.ALARM_FAULTBILL model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(FiberRMS.Model.AlarmManager.ALARM_FAULTBILL model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string BILLID)
        {
            return dal.Delete(BILLID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FiberRMS.Model.AlarmManager.ALARM_FAULTBILL GetModel(string BILLID)
        {

            return dal.GetModel(BILLID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<FiberRMS.Model.AlarmManager.ALARM_FAULTBILL> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List<FiberRMS.Model.AlarmManager.ALARM_FAULTBILL> modelList = new List<FiberRMS.Model.AlarmManager.ALARM_FAULTBILL>();
            int rowsCount = ds.Tables[0].Rows.Count;
            if (rowsCount > 0)
            {
                FiberRMS.Model.AlarmManager.ALARM_FAULTBILL model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new FiberRMS.Model.AlarmManager.ALARM_FAULTBILL();
                    model.BELONGDOMAIN = ds.Tables[0].Rows[n]["BELONGDOMAIN"].ToString();
                    model.BILLID = ds.Tables[0].Rows[n]["BILLID"].ToString();
                    model.ALARMNUMBER = ds.Tables[0].Rows[n]["ALARMNUMBER"].ToString();
                    model.ALARMLEVEL = ds.Tables[0].Rows[n]["ALARMLEVEL"].ToString();
                    model.PRIMALCAUSE = ds.Tables[0].Rows[n]["PRIMALCAUSE"].ToString();
                    if (ds.Tables[0].Rows[n]["STARTTIME"].ToString() != "")
                    {
                        model.STARTTIME = DateTime.Parse(ds.Tables[0].Rows[n]["STARTTIME"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["GENERICTIME"].ToString() != "")
                    {
                        model.GENERICTIME = DateTime.Parse(ds.Tables[0].Rows[n]["GENERICTIME"].ToString());
                    }
                    model.DISPATCHDESC = ds.Tables[0].Rows[n]["DISPATCHDESC"].ToString();
                    if (ds.Tables[0].Rows[n]["DISPOSETIME"].ToString() != "")
                    {
                        model.DISPOSETIME = DateTime.Parse(ds.Tables[0].Rows[n]["DISPOSETIME"].ToString());
                    }
                    model.DISPOSESTATUS = ds.Tables[0].Rows[n]["DISPOSESTATUS"].ToString();
                    model.REMARK = ds.Tables[0].Rows[n]["REMARK"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}

